<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/struts/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" media="all" href="script/jscalendar-1.0/calendar-win2k-cold-1.css" title="win2k-cold-1" />

<script type='text/javascript' src='script/prototype.js'></script>
<script type='text/javascript' src='script/common.js'></script>

<script type="text/javascript" src="script/jscalendar-1.0/calendar.js"></script>
<script type="text/javascript" src="script/jscalendar-1.0/lang/calendar-zh.js"></script>
<script type="text/javascript" src="script/jscalendar-1.0/calendar-setup.js"></script>
<script language="javascript">
function doAction(imethod, goalID) {
    if(imethod == 'delete') {
        var ret = confirm("你确信删除这项任务吗?");
        if(ret) {
            location.href = "goal.htm?method=delete&goalID=" + goalID;
        }
    } else {
        location.href = "goal.htm?method=" + imethod + "&goalID=" + goalID;
    }
}
</script>
<style type="text/css">
.smart {
padding-top:0.5em;
font-size:1em;
text-align:left;
list-style-position:inside;
}
</style>
</head>
<body>
<c:choose>
<c:when test="${empty goal}">
<c:set var="handler" value="goal.htm?method=create" />
</c:when>
<c:otherwise>
<c:set var="handler" value="goal.htm?method=update" />
</c:otherwise>
</c:choose>
<div id="content"><div id="content_inner">
<form name="goalForm" id="goalForm" action="${handler}"  method="post">
<TABLE id="goalTab" class="its" cellspacing="4" cellpadding="4">
<thead>
  <TR>
<TH colspan="3" align="center">
<select id="goalType" name="goalType">
<option value="1">长期目标</option>
<option value="2">中期目标</option>
<option value="3">短期目标</option>
<option value="4">本月目标</option>
<option value="5"">本周目标</option>
<option value="6">当天目标</option>
</select>
</TH>
  </TR>
  </thead>
  <TR>
    <TD width="10%" align="right">名称:</TD>
    <TD width="50%">
    <TEXTAREA NAME="goalName" id="goalName" ROWS="1" COLS="50">${goal.goalName}</TEXTAREA>
    </TD>
<td rowspan="3" align="left" valign="top" class="smart">
<ul>请遵循 SMART 原则
<li>具体的 Specific
<li>可衡量的 Measurable
<li>可达到的 Attainable
<li>相关的 Relevant
<li>基于时间的 Time-based
</ul>
</td>
  </TR>
  <TR>
    <TD align="right">描述:</TD>
    <TD>
    <TEXTAREA NAME="description" id="description" ROWS="8" COLS="50">${goal.description}</TEXTAREA>
    </TD>
  </TR>
<TR>
    <TD align="right">最后期限:</TD>
    <TD nowrap><div>
    <input NAME="deadline" size="20" type='text' id='deadline' 
    value="<fmt:formatDate value='${goal.deadline}' pattern='yyyy-MM-dd HH:mm:ss'/>"/>
    <input type='button' id='trigger1' value='...' />
<input NAME="createTime" size="20" type='hidden' 
    value="<fmt:formatDate value='${task.createTime}' pattern='yyyy-MM-dd HH:mm:ss'/>"/>
&nbsp;
类别:
<SELECT NAME="categoryID" ID="categoryID">
<c:forEach items="${categories}" var="entry">
        <OPTION VALUE="${entry.key}">${entry.value.description}
 </c:forEach>
</SELECT> </div>
</TD>

</TR>
  <TR>
    <TD colspan="3" align="center">
<br/><div>
    <input type="hidden" name="goalID" id="goalID" value="${goal.goalID}">
    <input type="hidden" name="goalType" id="goalType" value="${param.goalType}">
    <INPUT TYPE="submit" value="保存">&nbsp;&nbsp;
    <c:if test="${not empty goal}">
    <INPUT TYPE="button" id="finish" value="完成" onclick="javascript: doAction('finish',${goal.goalID})">
    &nbsp;&nbsp;
    <INPUT TYPE="button" id="delete" value="删除" onclick="javascript: doAction('delete',${goal.goalID})">
    </c:if>
    &nbsp;&nbsp;
    <INPUT TYPE="reset" value="取消" onclick="javascript:history.back()">
</div></TD>
  </TR>
  </TABLE>
</FORM>
</div><!-- content_inner -->
</div><!-- content -->

<script language="Javascript">
<c:if test="${not empty goal}">
var defaultGoalType = "" + "${goal.goalType}";
toSelect("goalType",defaultGoalType);
</c:if>
<c:if test="${empty goal}">
var defaultGoalType = "" + "${param.goalType}";
if(defaultGoalType=="0" || defaultGoalType=="") {
    defaultGoalType=6;
}
toSelect("goalType",defaultGoalType);
</c:if>

Calendar.setup({
    inputField     :    "deadline",      // id of the input field
    ifFormat       :    "%Y-%m-%d %H:%M:00",       // format of the input field
    showsTime      :    true,            // will display a time selector
    button         :    "trigger1",   // trigger for the calendar (button ID)
    singleClick    :    false,           // double-click mode
    step           :    1                // show all years in drop-down boxes (instead of every other year as default)
});

</script>